package game;

import effect.character.single.SingleCharacterEffect;
import effect.Effect;
import character.MyCharacter;
import effect.AreaEffect;
import misc.Vector3i;

public abstract class CombatUtil {

    /* Returns true if the attacker is in range to hit the target with its equipped weapon. */
    public static boolean checkAttackRange(MyCharacter attacker, MyCharacter target) {
	for(Vector3i occupiedLocation : target.getOccupiedLocations()) {
	    if(attacker.getInventory().getEquippedWeapon().getLocationsInRange().contains(occupiedLocation))
		return true;
	}
	return false;
    }

    public static boolean checkEffectRange(Effect effect) {
	if(effect instanceof AreaEffect) {
	    if(effect.getLocationsInRange().contains(((AreaEffect)effect).getTarget()))
		return true;
	} else if(effect instanceof SingleCharacterEffect) {
	    for(Vector3i occupiedLocation : ((SingleCharacterEffect)effect).getTarget().getOccupiedLocations()) {
		if(effect.getLocationsInRange().contains(occupiedLocation))
		    return true;
	    }
	}
	return false;
    }
}
